package com.fejal.bean;

import java.io.Serializable;

import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;

import org.hibernate.annotations.Cascade;
import org.hibernate.annotations.CascadeType;
import org.hibernate.annotations.Fetch;
import org.hibernate.annotations.FetchMode;

@Entity
public class Falta implements Serializable {


	private static final long serialVersionUID = 4751535049211241520L;
	
	@Id
	@GeneratedValue (strategy = GenerationType.AUTO)
	private int codigoFalta;
	private int mes;
	private int valor;
	
	@ManyToOne(fetch = FetchType.EAGER)
	@JoinColumn(name = "codigoHistorico", insertable = true, updatable = true, nullable=false)
	@Fetch(FetchMode.JOIN)
	@Cascade(CascadeType.SAVE_UPDATE)	
	private Historico historico;
	
	public int getCodigoFalta() {
		return codigoFalta;
	}
	public void setId(int codigoFalta) {
		this.codigoFalta = codigoFalta;
	}
	public int getMes() {
		return mes;
	}
	public void setMes(int mes) {
		this.mes = mes;
	}
	public int getValor() {
		return valor;
	}
	public void setValor(int valor) {
		this.valor = valor;
	}
	public Historico getHistorico() {
		return historico;
	}
	public void setHistorico(Historico historico) {
		this.historico = historico;
	}
	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + codigoFalta;
		return result;
	}
	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		Falta other = (Falta) obj;
		if (codigoFalta != other.codigoFalta)
			return false;
		return true;
	}
	
	
}
